package org.javaboy.demo.lettuce;

import io.lettuce.core.RedisClient;
import io.lettuce.core.api.StatefulRedisConnection;
import io.lettuce.core.api.sync.RedisCommands;

public class LettuceDemo {
    public static void main(String[] args) {
        //这个其实就是 HttpBasic 登录，用户名和密码之间用 : 隔开
        //http://username:password@www.javaboy.org/2019/0528/redis-lettuce.html
        // 创建客户端
        RedisClient redisClient = RedisClient.create("redis://123@centos.javaboy.org:6379");
        // 连接
        StatefulRedisConnection<String, String> connect = redisClient.connect();
        RedisCommands<String, String> sync = connect.sync();
        String s = sync.get("name");
        System.out.println("s = " + s);
        // 关闭连接
        connect.close();
    }
}
